<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

class CheckNullRoute extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'check:route';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
            $routes = app('router')->getRoutes();
            $nullRoutes = [];

            foreach ($routes as $index => $route) {
                if ($route === null) {
                    $nullRoutes[] = $index;
                }
            }

            if (!empty($nullRoutes)) {
                dd("发现 {$nullRoutes} 个 null 路由，位置索引：", $nullRoutes);
            }else {
                $this->info('没有发现 null 路由');
            }
    }
}
